pp108 : getCheckableItems Method

getCheckableItems Method


This method returns an array of all (un)checked tree items under the current item. The current item is also included.

Syntax

oTreeItems = treeID.getCheckableItems( bSelect ),oTreeItems = root. getCheckableItems ( bSelect ), oroTreeItems = treeItem. getCheckableItems ( bSelect )

Parameters

bSelect

Boolean, required. If 'true', the checked tree items are returned. If 'false' the unchecked tree items are returned.


Remarks


Only the tree items that are checkable are returned. This method can get time consuming, especially for large trees. Use this method on a tree item which is as deep in the tree as possible. For large trees it is better not to use this method on the treeID itself.

Example


The following example shows how the above method is used.

<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd" >
<html>
<head>
    <title>getCheckedItems example</title>
    <script src="/cordys/wcp/application.js"></script>
</head>
<script type="cordys/xml" id="menuData" >
    <menu>
         <Continent>
              <caption>Asia</caption>
              <Country>
                    <caption>India</caption>
                    <description>India is my Country</description>
              </Country>
              <Country>
                    <caption>Japan</caption>
                    <description>Japan popular for electronic trends</description>
              </Country>
        </Continent>
        <Continent>
              <caption>Europe</caption>
              <description>Europe</description>
              <Country>
                     <caption>The NetherLands</caption>
                     <description>The NetherLands</description>
               </Country>
               <Country>
                     <caption>UK</caption>
                     <description>UK</description>
               </Country>
        </Continent>
    </menu>
</script>
<script type="cordys/xml" xmlns="" id="MenuTreeSchema" >
    <TreeSchema>
          <searchPath>//menu/</searchPath>
          <Root>
                <description>Continents</description>
                <checkable>true</checkable>
                <checkChildren>false</checkChildren>
          </Root>
          <TreeItem id="ContinentID">
                <searchPath>Continent</searchPath>
                <description>caption</description>
                <checkable>true</checkable>
          </TreeItem>
          <TreeItem id="CountryID">
                <searchPath>Country</searchPath>
                <description>caption</description>
                <checkable>true</checkable>
          </TreeItem>
    </TreeSchema>
</script>
<script type="text/javascript">
    function getCheckableItems ()
       {
           var myTree = document.getElementById("myTree");
           var asiaNode = myTree.getItem("Asia");
           var items = asiaNode. getCheckableItems (true);
           var str = "";
           for ( var i=0 ; i<items.length ; i++ )
               {
                   str += cordys.getTextContent(items[i].getLabel()) + "\n";
               }
           application.notify("Checked under Asia:\n" + str);
      }
</script>
<body>
      <p>Example of the getCheckableItems method.</p>
      <p>Check a few treeItems and invoke button. Continents: checkChildren=false</p>
      <button onclick=" getCheckableItems ()">getCheckableItems (true) Asia</button>
	  <div cordysType="wcp.library.ui.Tree" id="myTree" treeData='menuData' treeSchema='MenuTreeSchema'> </div>

</body>
</html>

See Also


tree